<template>
  <a :href="url" v-text="text"></a>
</template>

<script>
import axios from "axios";
export default {
  name: "download",
  data() {
    const download = {
      makecode: {
        url: "https://www.hterobot.com/download/makecode",
        name: "makecode离线编程软件(windows)"
      },
      makecodemac: {
        url: "https://www.hterobot.com/download/makecodemac",
        name: "makecode离线编程软件(mac)"
      },
      doubao: {
        url: "https://www.hterobot.com/download/scratch",
        name: "DouBao编程软件(windows)"
      },
      doubaomac: {
        url: "https://www.hterobot.com/download/scratchmac",
        name: "DouBao编程软件(mac)"
      }
    };
    return {
      download,
      url: "https://www.hterobot.com",
      text: "官方网站"
    };
  },
  async created() {
    console.log(this.name, this.download[this.name]);
    try {
      let data = await axios.get(this.download[this.name].url);
      console.log(data);
    } catch (err) {
      console.log(err);
    }
  },
  props: {
    name: {
      type: String
    }
  }
};
</script>

